package com.tongjie.hotelbooking.im.conversation.service;

import com.tongjie.hotelbooking.im.conversation.entiry.Conversation;
import com.tongjie.hotelbooking.im.conversation.entiry.MemberConversation;
import com.tongjie.hotelbooking.im.conversation.repository.MemberConversationRepository;
import com.tongjie.hotelbooking.user.entity.User;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class MemberConversationService {

    @Resource
    private MemberConversationRepository memberConversationRepository;

    public List<MemberConversation> findMemberConversationsByMemberUser(User memberUser) {
        return this.memberConversationRepository.findMemberConversationsByMemberUser(memberUser);
    }

    public MemberConversation getCurrentMemberConversationByUsers(User currentUser, User targetUser) {
        return this.memberConversationRepository.getCurrentMemberConversationByUsers(currentUser, targetUser);
    }

    public List<MemberConversation> findMemberConversationByConversationId(Long conversationId) {
        return this.memberConversationRepository.findMemberConversationsByConversation(Conversation.builder().id(conversationId).build());
    }

}
